<template>
  <div style="text-align: center">
    <el-form ref="form" :model="form" label-width="80px" style="text-align: center;width: 50%">
      <el-form-item label="房间号">
        <el-input v-model="form.rid"></el-input>
      </el-form-item>
      <el-form-item label="房间类型">
        <el-select v-model="form.rtype" placeholder="请选择房间类型">
          <el-option label="单人间A款" value="1"></el-option>
          <el-option label="单人间B款" value="2"></el-option>
          <el-option label="双人间A款" value="3"></el-option>
          <el-option label="双人间B款" value="4"></el-option>
          <el-option label="三人间" value="5"></el-option>
          <el-option label="钟点房" value="6"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="房间差价">
        <el-input v-model="form.extraprice"></el-input>
      </el-form-item>
      <el-form-item label="房间备注">
        <el-input type="textarea" v-model="form.comment"></el-input>
      </el-form-item>
      <el-button type="primary" @click="addRoom()">立即添加</el-button>
      <el-button type="primary" @click="upRoom()">修改添加</el-button>

    </el-form>
  </div>
</template>

<script>
import instance from "@/untils";

export default {
  data() {
    return {
      form: {

      }
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    },
    addRoom(){
      instance.post('/room/addRoom/',this.form).then(res=>{
        if(res.data.status==200){
          this.$message({
            message:'添加成功',
            type:"success"
          });
          this.$router.push('/')
        }
      })
    },
    upRoom(){
      instance.post('/room/updateRoom',this.form).then(res=>{
        if(res.data.status==200){
          this.$message({
            message:res.data.msg,
            type:"success"
          });
          this.$router.push('/')
        }
      })
    }
  }
}
</script>
<style scoped>

</style>